import {createSlice} from '@reduxjs/toolkit'

const counterSlice = createSlice({
  name:'counter',
  initialState:{
    value:110
  },
  reducers:{ // 相当于vuex中的mutations，此处的reducers背后对reducer跟action做了默认映射
    increment(state,action){
      // console.log(payload);
      state.value += action.payload
    },
    decrement(state){
      state.value--
    }
  }
})

export const {increment,decrement} = counterSlice.actions //抛出actionCreator
export default counterSlice.reducer //抛出reducer函数